<template>
  <div class='specify-head'>
    <span v-for="(item, index) in formaltData" :key="index" :class="{'hover':true,'is-active':item.isActive}" @click="changeMenu(item)">{{item.label}}</span>

    <span v-for="(btn, index) in formaltBtnsData" :class="'ml-auto '+btn.class" :key="'btn_'+index" @click="doClick(btn)" >
      {{btn.label}}
    </span>
  </div>
</template>
<script>
export default {
  props:['headData0',"headBtnsData"],
  components: {},
  name: "",
  data() {
    return {
      menuData:[
        {label:"全部",isActive:true},
        {label:"卖家未报价",isActive:false},
        {label:"卖家已报价",isActive:false},
        {label:"卖家已拒绝",isActive:false},
        {label:"已取消",isActive:false},
      ]
    };
  },
  computed:{
    formaltData(){
      return this.headData0||this.menuData
    },
    formaltBtnsData(){
      return this.headBtnsData||[]
    }
  },
  methods: {
    /**
     * @name 改变状态
     */
    changeMenu(item){
      let data = this.headData0||this.menuData
      data.forEach(ele=>{ele.isActive=false})
      this.$set(item,'isActive',true)
      console.log("重新请求数据");
      this.$emit('refrash',item)
    },

    doClick(btn){
      if(btn.click){
          this[btn.click]()
      }
    },

    /**
     * @name 新增地址
     */
    addAddress(){
      this.$store.state.dias.addressAdd.show=true
    },

    /**
     * @name 清空积分记录
     */
    doClear(){
      console.log("清空积分记录");
      _g.apiPost('Integral/cleanIntegral.do').then(res=>{
        _g.toMessage(res)
        if(res.status==0){
          this.$emit('refrash',this.headData0.find(val=>val.isActive))
        }
      })
    }
  },
  created() {}
};
</script>
<style lang="scss" scoped>
.specify-head {
  height: 50px;
  padding: 0 10px;
  box-sizing: border-box;
  border-bottom: 1px solid #f2f2f2;
  line-height: 50px;
  display: flex;

  span{
    display: inline-block;
    min-width: 100px;
    text-align: center;
    line-height: 45px;
    box-sizing: border-box;
    font-size: 14px;
  }
  span.is-active{
    border-bottom: 3px solid $blue;
  }

  .btn{
    height: 30px;
    line-height: 30px;
    margin-top: 10px;
    color: #fff;
    margin-right: 10px;
  }
}
</style>